package group2.service.impl;

import group2.mapper.OrderMapper;
import group2.model.OrderDetail;
import group2.model.OrderInfo;
import group2.service.IOrderIService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 李显星
 * @date 2020/8/17 15:15
 **/
@Service("orderService")
public class OrderIServiceImpl implements IOrderIService {

    @Autowired
    OrderMapper orderMapper;


    /**
     * 添加订单
     * @return
     */
    @Override
    public int addOrder(OrderInfo order){
        return this.orderMapper.insertOrder(order);
    }


    /**
     * 添加订单详情
     * @param orderDetail
     */
    @Override
    public int addOrderDetail(OrderDetail orderDetail){
        return this.orderMapper.insertOrderDetail(orderDetail);
    }


    /**
     * 查询所有订单
     * @return
     */
    @Override
    public List<OrderInfo> findAll(){
        return this.orderMapper.selectAll();
    }


    /**
     * 查询进行中的订单
     * @return
     */
    @Override
    public List<OrderInfo> findOfProcessing(){
        return this.orderMapper.selectOfProcessing();
    }


    /**
     * 查询已完成的订单
     * @return
     */
    @Override
    public List<OrderInfo> findOfFinish(){
        return this.orderMapper.selectOfFinish();
    }


    /**
     * 查询已取消的订单
     */
    @Override
    public List<OrderInfo> findCancel(){
        return this.orderMapper.selectCancel();
    }


    /**
     * 按编号查询订单详情
     * @return
     */
    @Override
    public List<OrderDetail> findOrderDetailById(String orderId){
        return this.orderMapper.selectOrderDetailById(orderId);
    }


    /**
     * 查询最晚添加的订单编号
     * @return
     */
    @Override
    public String findOrderId(){
        return this.orderMapper.selectOrderId();
    }


    /**
     * 取消订单
     * @param orderId
     */
    @Override
    public int cancelOrder(String orderId){
        return this.orderMapper.cancelOrder(orderId);
    }


    /**
     * 删除订单及对应订单详情
     * @return
     */
    @Override
    public int deleteOrder(String orderId){
        return this.orderMapper.deleteOrder(orderId);
    }


    /**
     * 确认收货
     * @param orderId
     * @return
     */
    @Override
    public int confirmReceipt(String orderId){
        return this.orderMapper.confirmReceipt(orderId);
    }


}
